<template>
  <div class="oe-new-question" v-loading="loading">
    <top-tip :title="title"></top-tip>
    <div class="oe-new-contain">
      <div class="oe-new-select">
        <span class="oe-type">
          <a-select
            v-model="selectType1"
            @change="typechange"
            showSearch
            :disabled="this.mode == 'result' || this.editdisabled"
            :allowClear="true"
            optionFilterProp="children"
            placeholder="题型"
            style="width:120px"
          >
            <a-select-option v-for="(item, index) in typelist" :value="item.id" :index="index" :key="item.id">{{
              item.text
            }}</a-select-option>
          </a-select>
        </span>
        <span class="oe-easy">
          <a-select
            v-model="selectType2"
            @change="diffchange"
            showSearch
            :disabled="this.mode == 'result' || this.editdisabled"
            :allowClear="true"
            optionFilterProp="children"
            placeholder="难易程度"
            style="width:120px"
          >
            <a-select-option v-for="(item, index) in defficulty" :value="item.id" :index="index" :key="item.id">{{
              item.text
            }}</a-select-option>
          </a-select>
        </span>
        <span v-if="this.changeid >= 7" class="oe-easy">
          <a-button
            :disabled="this.mode == 'result' || this.editdisabled"
            class="childbutton"
            @click="typechangechild(1)"
            type="primary"
            >添加单选题</a-button
          >
          <a-button
            :disabled="this.mode == 'result' || this.editdisabled"
            class="childbutton"
            @click="typechangechild(2)"
            type="primary"
            >添加多选题</a-button
          >
          <a-button
            :disabled="this.mode == 'result' || this.editdisabled"
            class="childbutton"
            @click="typechangechild(3)"
            type="primary"
            >添加判断题</a-button
          >
          <!-- <a-select
            v-model="selectTypechild"
            @change="typechangechild"
            showSearch
            :disabled="this.mode == 'result'"
            optionFilterProp="children"
            placeholder="添加子题目"
            style="width:120px"
          >
            <a-select-option v-for="(item, index) in typelistchild" :value="item.id" :index="index" :key="item.id">{{
              item.text
            }}</a-select-option>
          </a-select> -->
        </span>
        <!-- <a-tooltip placement="bottom" title=" 图片粘贴完成后要在图片后空一格才能保存成功">
          <span class="ant-texticon"><a-icon type="exclamation-circle" class="ant-icon" />图片上传说明</span>
        </a-tooltip> -->
      </div>
      <div v-if="changeid" class="oe-new-content">
        <div v-if="mode == 'edit'" class="oe-new-question__btn">
          <a-button @click="setTimeoutjudge('next')" type="primary">保存</a-button>
          <a-button :disabled="this.editdisabled" @click="setTimeoutjudge" type="primary">保存新建下一题</a-button>
          <a-button @click="$router.back()">取消</a-button>
        </div>
      </div>
      <div v-else class="oe-new-content">
        <p class="oe-content-p">
          请选择题目类型和难度
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import topTip from '@/components/top-tip/index.vue';
export default {
  components: {
    topTip,
  },
  data() {
    return {
      typelist: [
        { id: 1, text: '单选题(客观)' },
        { id: 2, text: '多选题(客观)' },
        { id: 3, text: '判断(客观)' },
        { id: 4, text: '填空题(主观)' },
        { id: 5, text: '问答题(主观)' },
        { id: 6, text: '匹配题(客观)' },
        { id: 7, text: '阅读理解(客观)' },
        { id: 8, text: '完形填空(客观)' },
        { id: 9, text: '视听题(客观)' }
      ],
      typelistchild: [
        { id: 1, text: '单选题(客观)' },
        { id: 2, text: '多选题(客观)' },
        { id: 3, text: '判断(客观)' }
      ],
      selectTypechild: undefined,
      loading: false,
      mode: '',
      changetype: '',
      typeid: '',
      changeid: '',
      time: '',
      questionId: '',
      selectType1: undefined,
      editdisabled: false,
      //难度
      defficulty: [
        { id: 1, text: '非常简单' },
        { id: 2, text: '简单' },
        { id: 3, text: '一般' },
        { id: 4, text: '困难' },
        { id: 5, text: '非常困难' }
      ],
      selectType2: undefined,
      paperList: [],
      title: [{ text: '新建题目' }]
    };
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      let id = vm.$route.params.quizid;
      vm.init();
      if (id && vm.$route.name == 'editQuestion') {
        vm.title = [{ text: '编辑题目' }];
        vm.mode = 'edit';
        vm.editdisabled = true;
        vm.previewQuestion();
      } else if (id && vm.$route.name == 'detailQuestion') {
        vm.title = [{ text: '查看题目' }];
        vm.mode = 'result';
        vm.previewQuestion();
      }
      if (vm.$route.name == 'newQuestion') {
        vm.mode = 'edit';
      }
    });
  },
  methods: {
    diffchange(val) {
      this.diffid = val;
    },
    //查看题目
    previewQuestion() {
      this.loading = true;
      this.$http
        .post('/api/design/questionbank/previewQuestion', {
          questionId: this.$route.params.quizid
        })
        .then((res) => {
          this.loading = false;
          let options = [];
          let answers = [];
          let answer = [];
          let f_params = {};
          switch (res.question.questionType) {
            case 1:
            case 2:
              this.selectType1 = res.question.questionType;
              this.selectType2 = res.question.difficultLevel;
              this.typeid = res.question.questionType - 1;
              this.paperList[this.typeid].id = res.question.Id;
              this.paperList[this.typeid].content = res.question.allTitle;
              this.paperList[this.typeid].quesFileList = res.question.fileList;
              this.paperList[this.typeid].answer = res.question.answer.split(',').map((n) => parseInt(n, 10));
              this.paperList[this.typeid].analysis = res.question.resultAnalysis;
              this.paperList[this.typeid].options = [];
              if (res.answerList && res.answerList.length) {
                res.answerList.forEach((op) => {
                  this.paperList[this.typeid].options.push({
                    content: op.Content
                  });
                });
              }
              this.changetype = res.question.questionType;
              this.changeid = res.question.questionType;
              this.questionId = res.question.Id;
              break;
            case 3:
              this.selectType1 = res.question.questionType;
              this.selectType2 = res.question.difficultLevel;
              this.typeid = 0;
              this.paperList = [];
              options = [
                { value: 1, content: '正确' },
                { value: 0, content: '错误' }
              ];
              if (res.question.answer) {
                let arr = res.question.answer
                  ? res.question.answer.split(',').map((i) => {
                      return isNaN(Number(i)) ? i : Number(i);
                    })
                  : Number(res.question.answer);
                answers = Array.prototype.slice.call(arr);
                answer = answers;
              }
              f_params = {
                id: res.question.Id,
                type: res.question.questionType,
                analysis: res.question.resultAnalysis,
                content: res.question.allTitle,
                standard: answers,
                answer: answer,
                options
              };
              this.paperList[this.typeid] = f_params;
              this.paperList[this.typeid].quesFileList = res.question.fileList;
              this.changetype = res.question.questionType;
              this.changeid = res.question.questionType;
              this.questionId = res.question.Id;
              break;
            case 4:
            case 5:
            case 6:
              if (res.question.questionType != 4) {
                this.selectType1 = res.question.questionType - 1;
                this.typeid = res.question.questionType - 2;
              } else {
                this.selectType1 = res.question.questionType;
                this.typeid = res.question.questionType - 1;
              }
              this.selectType2 = res.question.difficultLevel;
              this.paperList[this.typeid].id = res.question.Id;
              this.paperList[this.typeid].content = res.question.allTitle;
              this.paperList[this.typeid].quesFileList = res.question.fileList;
              if (res.question.questionType == 6) {
                this.paperList[this.typeid].answer = res.question.answer;
              } else {
                res.question.optionList.forEach((item) => {
                  this.paperList[this.typeid].answer.push(item.Content);
                });
              }

              this.paperList[this.typeid].analysis = res.question.resultAnalysis;
              this.paperList[this.typeid].options = [];
              if (res.question.optionList && res.question.optionList.length) {
                res.question.optionList.forEach((op) => {
                  this.paperList[this.typeid].options.push({
                    content: op.Content
                  });
                });
              }
              this.changetype = res.question.questionType;
              this.changeid = res.question.questionType - 1;
              this.questionId = res.question.Id;
              break;
            case 7:
              this.selectType1 = res.question.questionType - 1;
              this.selectType2 = res.question.difficultLevel;
              this.typeid = 0;
              this.paperList = [];
              options = {};
              options.s = [];
              options.m = [];
              if (res.question.answer) {
                let s = res.question.answer.replace(/,$/, '');
                let arr = s.split(',')
                  ? s.split(',').map((i) => {
                      return isNaN(Number(i)) ? i : Number(i);
                    })
                  : Number(s);
                answers = Array.prototype.slice.call(arr);
                answer = answers;
              }
              if (res.question.optionList && res.question.optionList.length) {
                res.question.optionList.forEach((op) => {
                  options.s.push({
                    value: op.SortOrder,
                    content: op.OptionContent
                  });
                });
              }
              if (res.question.questionAnswer && res.question.questionAnswer.length) {
                res.question.questionAnswer.forEach((op) => {
                  options.m.push({
                    value: op.SortOrder,
                    content: op.OptionAnswerContent
                  });
                });
              }
              f_params = {
                id: res.question.Id,
                type: res.question.questionType,
                analysis: res.question.resultAnalysis,
                content: res.question.allTitle,
                standard: answers,
                answer: answer,
                options: options
              };
              this.questionId = res.question.Id;
              this.changetype = res.question.questionType;
              this.changeid = res.question.questionType - 1;
              this.paperList[this.typeid] = f_params;
              this.paperList[this.typeid].quesFileList = res.question.fileList;
              break;
            case 8:
            case 9:
            case 11:
              if (res.question.questionType == 11) {
                this.selectType1 = res.question.questionType - 2;
              } else {
                this.selectType1 = res.question.questionType - 1;
              }
              this.selectType2 = res.question.difficultLevel;
              this.typeid = 0;
              this.paperList = [];
              if (res.subQuestionList && res.subQuestionList.length) {
                res.subQuestionList.forEach((op) => {
                  let c_option = [];
                  let c_answers = [];
                  let c_answer = [];
                  if (op.subAnswer) {
                    let arr = op.subAnswer.split(',')
                      ? op.subAnswer.split(',').map((i) => {
                          return isNaN(Number(i)) ? i : Number(i);
                        })
                      : Number(op.subAnswer);
                    c_answers = Array.prototype.slice.call(arr);
                    c_answer = c_answers;
                  }
                  // 如果是里面的判断
                  if (op.subQuestionType == 3) {
                    c_option = [
                      { value: 1, content: '正确' },
                      { value: 0, content: '错误' }
                    ];
                  } else {
                    // 如果是里面的单选和多选
                    if (op.subOptionList && op.subOptionList.length) {
                      op.subOptionList.forEach((an) => {
                        c_option.push({
                          value: an.SortOrder,
                          content: an.Content
                        });
                      });
                    }
                  }
                  let c_s_params = {
                    id: op.subQuestionId,
                    type: op.subQuestionType,
                    content: op.subQuestionTitle,
                    options: c_option,
                    answer: c_answer,
                    isShowQuesType: true
                  };
                  options.push(c_s_params);
                });
              }
              f_params = {
                id: res.question.Id,
                type: res.question.questionType,
                analysis: res.question.resultAnalysis,
                content: res.question.allTitle,
                standard: answers,
                answer: res.question.answer.split(','),
                options
              };
              this.questionId = res.question.Id;
              this.changetype = res.question.questionType;
              this.paperList[this.typeid] = f_params;
              this.paperList[this.typeid].quesFileList = res.question.fileList;
              if (res.question.questionType == 8 || res.question.questionType == 9) {
                this.changeid = res.question.questionType - 1;
              } else {
                this.changeid = res.question.questionType - 2;
              }
              break;
            default:
              break;
          }
        });
    },
    // 去除前后空格
    Trim(str) {
      return str.replace(/(^\s*)|(\s*$)/g, '');
    },
    setTimeoutjudge(val) {
      setTimeout(() => {
        this.judge(val);
      }, 200);
    },
    //保存题目
    judge(val) {
      //判断必填
      let title = this.paperList[this.typeid].content;
      let answer = this.paperList[this.typeid].answer;
      let label = [];
      let tkanswer = [];
      let labels = [];
      let labelm = [];
      if (this.changeid != 6) {
        this.paperList[this.typeid].options.forEach((e, index) => {
          label.push(e.content);
        });
      }
      let flag = false;
      for (let i = 0; i < label.length; i++) {
        if (!this.Trim(label[i]) || label[i].match(/\W(请输入内容)/g)) {
          flag = false;
          break;
        } else {
          flag = true;
        }
      }
      let flag4 = false;

      let flags = false;
      let flagm = false;
      switch (this.changeid) {
        case 1:
        case 2:
          if (!flag || title == '' || title.match(/\W(请输入内容)/g) || answer == '') {
            this.$message.warning('请填写题干、选项、答案');
          } else {
            if (val == 'next') {
              this.saveQues();
              this.$router.back();
            } else {
              this.saveQues();
            }
          }

          break;
        case 3:
          if (title == '' || title.match(/\W(请输入内容)/g) || answer == '') {
            this.$message.warning('请填写题干、选项、答案');
          } else {
            if (val == 'next') {
              this.saveQues();
              this.$router.back();
            } else {
              this.saveQues();
            }
          }
          break;
        case 4:
          this.paperList[this.typeid].options.forEach((e, index) => {
            label.push(e.content);
            tkanswer.push(this.paperList[this.typeid].answer[index]);
          });
          for (let i = 0; i < tkanswer.length; i++) {
            if (!this.Trim(tkanswer[i]) || tkanswer[i].match(/\W(请输入内容)/g)) {
              flag4 = false;
              break;
            } else {
              flag4 = true;
            }
          }
          if (!flag4 || title == '' || title.match(/\W(请输入内容)/g)) {
            this.$message.warning('请填写题干、选项、答案');
          } else {
            if (val == 'next') {
              this.saveQues();
              this.$router.back();
            } else {
              this.saveQues();
            }
          }
          break;
        case 5:
          if ((title == '' || title.match(/\W(请输入内容)/g))) {
            this.$message.warning('请填写题干、选项、答案5');
          } else {
            if (val == 'next') {
              this.saveQues();
              this.$router.back();
            } else {
              this.saveQues();
            }
          }
          break;
        case 6:
          this.paperList[this.typeid].options.s.forEach((e, index) => {
            labels.push(e.content);
          });
          this.paperList[this.typeid].options.m.forEach((e, index) => {
            labelm.push(e.content);
          });
          for (let i = 0; i < labels.length; i++) {
            if (!this.Trim(labels[i]) || labels[i].match(/\W(请输入内容)/g)) {
              flags = false;
              break;
            } else {
              flags = true;
            }
          }
          for (let i = 0; i < labelm.length; i++) {
            if (!this.Trim(labelm[i]) || labelm[i].match(/\W(请输入内容)/g)) {
              flagm = false;
              break;
            } else {
              flagm = true;
            }
          }
          if (
            title == '' ||
            title.match(/\W(请输入内容)/g) ||
            !flags ||
            !flagm ||
            this.paperList[this.typeid].answer.length != this.paperList[this.typeid].options.s.length
          ) {
            this.$message.warning('请填写题干、选项、答案');
          } else {
            if (val == 'next') {
              this.saveQues();
              this.$router.back();
            } else {
              this.saveQues();
            }
          }
          break;
        case 7:
        case 8:
        case 9:
          var label7 = [];
          var laeblson = false;
          var flag7 = false;
          var flag8 = false;
          this.paperList[this.typeid].options.forEach((e) => {
            e.options.forEach((es, index) => {
              label7.push(es.content);
            });
            for (let i = 0; i < label7.length; i++) {
              if (!this.Trim(label7[i]) || label7[i].match(/\W(请输入内容)/g)) {
                laeblson = false;
                break;
              } else {
                laeblson = true;
              }
            }
            if (e.type == 1 || e.type == 2) {
              if (!laeblson || e.content == '' || e.content.match(/\W(请输入内容)/g) || e.answer == '') {
                flag7 = true;
              }
            } else {
              if (e.content == '' || e.content.match(/\W(请输入内容)/g) || e.answer == '') {
                flag8 = true;
              }
            }
          });
          if (flag7 || flag8 || title == '' || title.match(/\W(请输入内容)/g)) {
            this.$message.warning('请填写题干、选项、答案');
          } else {
            if (val == 'next') {
              this.saveQues();
              this.$router.back();
            } else {
              this.saveQues();
            }
          }
          break;
      }
    },
    saveQues() {
      let datajson = [];
      let subdata = [];
      let answers = [];
      let subjson = [];
      let booltf = '';
      this.loading = true;
      let slecte = '';

      if (this.changeid != 6) {
        if (this.changeid == 5) {
          answers = this.paperList[this.typeid].standard;
        }
        this.paperList[this.typeid].options.forEach((e, index) => {
          switch (this.changeid) {
            case 1:
              if (this.paperList[this.typeid].answer == index) {
                booltf = true;
              } else {
                booltf = false;
              }
              datajson.push({
                SortOrder: index,
                Content: e.content,
                isAnswer: booltf
              });
              slecte = this.paperList[this.typeid].answer.join(',');
              break;
            case 2:
              if (this.paperList[this.typeid].answer.includes(index)) {
                booltf = true;
              } else {
                booltf = false;
              }
              datajson.push({
                SortOrder: index,
                Content: e.content,
                isAnswer: booltf
              });
              slecte = this.paperList[this.typeid].answer.join(',');
              break;
            case 3:
              answers = this.paperList[this.typeid].answer.join(',');
              slecte = this.paperList[this.typeid].answer.join(',');
              break;
            case 4:
              answers.push({
                SortOrder: index,
                Content: this.paperList[this.typeid].answer[index]
              });
              datajson.push({
                SortOrder: index,
                Content: this.paperList[this.typeid].answer[index],
                isAnswer: true
              });
              slecte = this.paperList[this.typeid].answer.join(',');
              break;
            case 6:
              slecte = this.paperList[this.typeid].answer.join(',');
              break;
            case 7:
            case 8:
            case 9:
              var c_options = [];
              if (e.type == 1 || e.type == 2) {
                e.options.forEach((c_op, index) => {
                  c_options.push({
                    SortOrder: index,
                    Content: c_op.content,
                    isAnswer: e.answer.includes(index)
                  });
                });
              }
              subdata.push({
                Id: e.id,
                Title: e.content,
                DataJson: JSON.stringify(c_options),
                answer: e.answer.join(','),
                SubQuestionType: e.type,
                quesFileList: e.quesFileList
              });
              slecte = this.paperList[this.typeid].answer.join(',');
              break;
          }
        });
      } else {
        this.paperList[this.typeid].options.s.forEach((e, index) => {
          datajson.push({
            SortOrder: index,
            optionContent: e.content,
            optionSelectContent: this.paperList[this.typeid].answer[index]
          });
        });
        this.paperList[this.typeid].options.m.forEach((e, index) => {
          answers.push({
            SortOrder: index,
            optionAnswerContent: e.content
          });
        });
        answers = JSON.stringify(answers);
      }
      if (this.changeid == 4) {
        answers = JSON.stringify(answers);
      }
      this.$http
        .post('/api/design/questionbank/saveQues', {
          questionId: this.questionId, //题目Id
          courseId: this.$route.params.addid, //课程Id
          knowledgeId: '', //知识点Id
          questionTitle: this.paperList[this.typeid].content, //题目标题
          jsonUrl: JSON.stringify(this.paperList[this.typeid].quesFileList), //题目附件
          difficultyLevel: this.selectType2, //题目难度1.非常简单，2.简单，3.一般，4.困难，5.非常困难
          questionType: this.changetype, //题目类型 1.单选题(客观),2.多选题(客观),3.判断(客观),5.填空题(主观),6.问答题(主观),7.匹配题(客观),8.阅读理解(客观),9.完形填空(客观),11.视听题(客观)
          selectContent: slecte, //题目答案(选择题)
          answers: answers, //题目答案 this.paperList[this.typeid].answer.join(',')
          dataJson: JSON.stringify(datajson), //题目数据json
          analysis: this.paperList[this.typeid].analysis, //解析
          keyWord: '', //关键字(只针对填空，问答题进行批阅，多个关键字英文逗号隔开)
          subQuestions: JSON.stringify(subdata) //子题目
        })
        .then((res) => {
          this.loading = false;
          if (res.code == 1) {
            this.$message.success(res.msg);
            this.selectType1 = undefined;
            this.selectType2 = undefined;
            this.changeid = undefined;
            this.questionId = '';
            this.init();
          } else {
            this.$message.error(res.msg);
          }
        });
    },
    init() {
      this.paperList = [
        {
          id: '',
          type: 1,
          isShowQuesType: true,
          content: '请输入内容',
          quesFileList: [],
          options: [
            {
              content: '请输入内容'
            },
            {
              content: '请输入内容'
            },
            {
              content: '请输入内容'
            },
            {
              content: '请输入内容'
            }
          ],
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 2,
          isShowQuesType: true,
          content: '请输入内容',
          quesFileList: [],
          options: [
            {
              content: '请输入内容'
            },
            {
              content: '请输入内容'
            },
            {
              content: '请输入内容'
            },
            {
              content: '请输入内容'
            }
          ],
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 3,
          content: '请输入内容',
          quesFileList: [],
          isShowQuesType: true,
          options: [
            {
              value: 1,
              content: '正确'
            },
            {
              value: 0,
              content: '错误'
            }
          ],
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 4,
          content: '',
          quesFileList: [],
          options: [],
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 6,
          content: '请输入内容',
          quesFileList: [],
          options: [],
          answer: [],
          analysis: ''
          // standard: []
        },
        {
          id: '',
          type: 7,
          content: '请输入内容',
          quesFileList: [],
          options: {
            s: [
              {
                content: '请输入内容'
              },
              {
                content: '请输入内容'
              }
            ],
            m: [
              {
                content: '请输入内容'
              },
              {
                content: '请输入内容'
              }
            ]
          },
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 8,
          content: '请输入内容',
          quesFileList: [],
          options: [
            {
              id: '',
              type: 1,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                }
              ],
              answer: [],
              analysis: ''
            },
            {
              id: '',
              type: 2,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                }
              ],
              answer: [],
              analysis: ''
            },
            {
              id: '',
              type: 3,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  value: 1,
                  content: '正确'
                },
                {
                  value: 0,
                  content: '错误'
                }
              ],
              answer: [],
              analysis: ''
            }
          ],
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 9,
          content: '请输入内容',
          quesFileList: [],
          options: [
            {
              id: '',
              type: 1,
              content: '请输入内容',
              isShowQuesType: true,
              options: [
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                }
              ],
              answer: [],
              analysis: ''
            },
            {
              id: '',
              type: 2,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                }
              ],
              answer: [],
              analysis: ''
            },
            {
              id: '',
              type: 3,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  value: 1,
                  content: '正确'
                },
                {
                  value: 0,
                  content: '错误'
                }
              ],
              answer: [],
              analysis: ''
            }
          ],
          answer: [],
          analysis: ''
        },
        {
          id: '',
          type: 11,
          content: '请输入内容',
          quesFileList: [],
          options: [
            {
              id: '',
              type: 1,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                }
              ],
              answer: [],
              analysis: ''
            },
            {
              id: '',
              type: 2,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                },
                {
                  content: '请输入内容'
                }
              ],
              answer: [],
              analysis: ''
            },
            {
              id: '',
              type: 3,
              content: '请输入内容',
              quesFileList: [],
              isShowQuesType: true,
              options: [
                {
                  value: 1,
                  content: '正确'
                },
                {
                  value: 0,
                  content: '错误'
                }
              ],
              answer: [],
              analysis: ''
            }
          ],
          answer: [],
          analysis: ''
        }
      ];
    },
    typechange(val) {
      this.changeid = val;
      this.typeid = val - 1;
      if (val >= 4 && val < 9) {
        this.changetype = val + 1;
      } else if (val == 9) {
        this.changetype = val + 2;
      } else {
        this.changetype = val;
      }
    },
    typechangechild(val) {
      this.paperList[this.typeid].options.push(this.paperList[val - 1]);
    }
  }
};
</script>

<style></style>
